import { reqGoodDetailInfoData } from '@/api'

const state = {
  goodDetailInfo:{}
}
const actions = {
  async getGoodDetailInfoData({commit},id) {
    const result = await reqGoodDetailInfoData(id)
    if (result.code === 200) {
      commit('SAVE_GOOD_DETAIL_INFO_DATA', result.data)
     
    } else {
      console.log(result.message);
    }
  }

}
const mutations = {
  SAVE_GOOD_DETAIL_INFO_DATA(state,data) {
    state.goodDetailInfo=data
  },

  //更改放大镜图片的默认图片链接
  UPDATE_IMG_DEFAULT_URL(state, imgUrl) {
    state.goodDetailInfo.skuInfo.skuDefaultImg=imgUrl
  }
}
const getters = {
  //手机详情面包屑
  mobile_crumbs(state) {
   return state.goodDetailInfo.categoryView||{}
  },
  //手机详情参数
  mobile_parameters(state) {
   return state.goodDetailInfo.skuInfo||{}
  },

  //手机详情版本参数
  mobile_versions(state) {
    return state.goodDetailInfo.spuSaleAttrList||{}
  }
}
export default {
  namespaced: true,
  state,
  actions,
  getters,
  mutations
}